package com.bjpowernode.redis;

import com.bjpowernode.utils.RedisUtils;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Transaction;

import java.util.List;

public class Jedis_dome {

    public static void main(String[] args) {

/*        Jedis jedis = new Jedis("192.168.45.128",6379);
        jedis.flushDB();
        String set = jedis.set("str1", "java");
        String set1 = jedis.set("str2", "php");
        System.out.println(set);
        System.out.println(set1);
//        关闭事务
        jedis.close();*/
//        获取jedis连接池
/*        JedisPool open = RedisUtils.open("192.168.45.128",6379);
//        获取连接池对象中获取连接对象
        Jedis jedis = open.getResource();
        String set = jedis.set("str1", "java1");
        String set1 = jedis.set("str2", "php1");

        open.close();*/

/*        JedisPool open = RedisUtils.open("192.168.45.128", 6379);
        Jedis resource = open.getResource();
        Long lpush = resource.lpush("list01", "php", "java", "python", "go");

        System.out.println(lpush);
        open.close();*/

        JedisPool open = RedisUtils.open("192.168.45.128", 6379);
        Jedis resource = open.getResource();
//
        Transaction multi = resource.multi();
        multi.set("str3","ccc");
        multi.set("str4","ddd");
        List<Object> exec = multi.exec();
        for (Object o : exec) {
            System.out.println(o);
        }
        open.close();

        System.out.println("git结合idea使用！");
        System.out.println("git结合idea使用！");



    }
}
